<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3150：[Ctsc2013]猴子</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2013]猴子</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2013]猴子</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Ctsc2013]猴子                </h1>
                <p>时间限制：20s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>
<div style="margin: 6pt 0cm 0pt 20pt"><span style="font-size: medium"><span style="color: black">小</span><span style="color: black">Q</span><span style="color: black">和小</span><span style="color: black">M</span><span style="color: black">最近发明了一种卡牌游戏，叫猴子大战。 </span></span></div>
<div style="margin: 6pt 0cm 0pt 20pt"><span style="font-size: medium"><span style="color: black">游戏最初小</span><span style="color: black">Q</span><span style="color: black">和小</span><span style="color: black">M</span><span style="color: black">各会取得一部分猴子牌。每局游戏，他们两个需要分别等概率地</span></span><span style="font-size: medium"><span style="color: black">从自己的猴子牌中抽取一张进行战斗。获胜的一方将获得双方的猴子牌。如果一方获得了所</span></span><span style="font-size: medium"><span style="color: black">有的猴子牌，则该方获得整场游戏的胜利。否则游戏将一直进行下去。 </span></span><span style="font-size: medium"><span style="color: black">在进行了若干场比赛以后，小</span><span style="color: black">Q</span><span style="color: black">和小</span><span style="color: black">M</span><span style="color: black">算出了一张胜率表，为每张猴子牌之间进行战</span></span></div>
<div style="margin: 5pt 0cm 0pt"><span style="font-size: medium"><span style="color: black">斗双方获胜的概率。由于每场战斗一定会决出胜负，而且胜率不受先后顺序的影响，因此对</span></span><span style="font-size: medium"><span style="color: black">于任意的两张猴子牌</span><span style="color: black">A</span><span style="color: black">和</span><span style="color: black">B</span><span style="color: black">，</span><span style="color: black">A</span><span style="color: black">战胜</span><span style="color: black">B</span><span style="color: black">的概率加</span><span style="color: black">B</span><span style="color: black">战胜</span><span style="color: black">A</span><span style="color: black">的概率为</span><span style="color: black">1</span><span style="color: black">。 </span></span><span style="font-size: medium"><span style="color: black">由于自己老是输给小</span><span style="color: black">M</span><span style="color: black">，小</span><span style="color: black">Q</span><span style="color: black">开始怀疑自己每次拿到的猴子牌是否能获得胜利。他希</span></span><span style="font-size: medium"><span style="color: black">望求出自己拿到的每种猴子牌组合的获胜的概率。 </span></span><span style="font-size: medium"><span style="color: black">由于小</span><span style="color: black">Q</span><span style="color: black">接下来还有在</span><span style="color: black">CD</span><span style="color: black">市体育中心数以万计的运动计划，因此这个问题只能交给</span></span><span style="font-size: medium"><span style="color: black">你来解决了。 </span></span></div>
</div>
<p><span style="font-size: medium"><br clear="all" />
</span></p>
<div>
<div><span style="font-size: medium">&nbsp;</span></div>
</div></p><hr/><h3>输入格式</h3><p><div style="margin: 6pt 0cm 0pt 20pt"><span style="font-size: medium"><span style="color: black">输入的第一行包含两个正整数</span><span style="color: black">n</span><span style="color: black">和</span><span style="color: black">m</span><span style="color: black">，表示猴子牌的总张数和需要求的猴子牌组合的个</span></span><span style="font-size: medium"><span style="color: black">数。 </span></span><span style="font-size: medium"><span style="color: black">接下来有</span><span style="color: black">n</span><span style="color: black">行，每行包含</span><span style="color: black">n</span><span style="color: black">个实数，每个实数保留了两位小数。这</span><span style="color: black">n</span><span style="color: black">行中，其中第</span><span style="color: black">i</span><span style="color: black">行</span></span><span style="font-size: medium"><span style="color: black">第</span><span style="color: black">j列的数为P</span><sub><span style="color: black">i,j</span></sub><span style="color: black">，表示第</span><span style="color: black">i</span><span style="color: black">张猴子牌战胜第</span><span style="color: black">j</span><span style="color: black">张猴子牌的概率。保证P</span><sub><span style="color: black">i,j</span></sub> <span style="color: black">+ </span><span style="color: black">P</span><sub><span style="color: black">j,i</span></sub> &nbsp;<span style="color: black">= </span><span style="color: black">&nbsp;</span><span style="color: black">1。特别</span></span><span style="font-size: medium"><span style="color: black">地，P</span><sub><span style="color: black">i,j</span></sub> <span style="color: black">= 0.5</span><span style="color: black">，没有特殊意义。 </span></span><span style="font-size: medium"><span style="color: black">最后又</span><span style="color: black">m</span><span style="color: black">行。每行包含一个长度为</span><span style="color: black">n</span><span style="color: black">的无空格分隔的</span><span style="color: black">01</span><span style="color: black">串，表示一个猴子牌的组合。</span></span><span style="font-size: medium"><span style="color: black">其中第</span><span style="color: black">i</span><span style="color: black">个字符如果为</span><span style="color: black">0</span><span style="color: black">，表示最初第</span><span style="color: black">i</span><span style="color: black">张牌在小</span><span style="color: black">M</span><span style="color: black">处，否则表示在小</span><span style="color: black">Q</span><span style="color: black">处。 </span></span></div></p><hr/><h3>输出格式</h3><p><p><span style="font-size: medium"><span style="color: black">输出</span><span style="color: black">m</span><span style="color: black">行，每行一个实数，四舍五入保留八位小数（请强制输出八位浮点数），一次表</span></span><span style="font-size: medium"><span style="color: black">示每个给定的猴子牌组合下小</span><span style="color: black">Q</span><span style="color: black">获胜的概率。 </span></span></p>
<p></p></p><hr/><h3>样例输入</h3><pre>3 4 
0.50 0.60 0.40 
0.40 0.50 0.70 
0.60 0.30 0.50 
110 
011 
111 
000 


 

 
 
</pre><hr/><h3>样例输出</h3><pre>0.71304348 
0.66086957 
1.00000000 
0.00000000 
 </pre><hr/><h3>提示</h3><p><p><br />
【评分方法】 <br />
你的答案的每一行如果与我们给定的参考答案的差别均不超过2&times;10-6，则获得该测试点的得分，否则不得分。 参考答案保证与真实值的差别不超过10-8，因此如果你输出的答案保证与真实值差别不超过2&times;10-6 &mdash; 2&times;10-8，才能保证正确。</p></p><hr/><h3>题目来源</h3><p>vfleaking提供spj</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3150" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3150" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>